<script setup lang="ts">
import { inject } from "vue";

const realMoney = inject<number>("money", 0);

const costMoneyFunc = inject<(money: number) => void>("cost");
const cutMoney = () => {
  // 要花爷爷的钱
  if (costMoneyFunc) {
    costMoneyFunc(8999);
  }
};
</script>

<template>
  <h3>我是孙子</h3>
  <p>得到爷爷给的零花钱：{{ realMoney }}</p>
  <button @click="cutMoney">买一个最新款的华为Meta70Pro保时捷版本</button>
</template>

<style scoped></style>
